<?php
class Events_Model extends ORM {
	
	protected $table_name = 'events';
	protected $primary_key = 'events_id';
	protected $col_sort_order = 'events_sort_order';
	protected $col_events_status = 'events_status';
	protected $sorting = array('events_update_date' => 'desc');
	
	public function get()
	{
		$this->db->from($this->table_name);
		$this->db->select('*');
		$this->db->orderby($this->col_sort_order,'desc');
		$this->db->orderby($this->primary_key,'desc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
	
	public function get_with_active($language)
	{
		$this->db->select('*');
		$this->db->from($this->table_name);
		$this->db->join('events_content', 'events_content.events_id', 'events.events_id');
		$this->db->where('events_content.languages_id',$language);
		$this->db->where($this->col_events_status,'1');
		$this->db->orderby('events.'.$this->col_sort_order,'desc');
		$this->db->orderby('events.'.$this->primary_key,'desc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
}
?>